package day_2022_7_to_8.day48;

/**
 * @author haomin
 * @date 2022/08/28 10:31
 **/
public class Day43_1_Num793_PreimageSizeFZF {
    class Solution {
        public int preimageSizeFZF(int k) {
            int last = 1;
            while(last < k)
                last = 5 * last + 1;
            while(last > 1){
                if(last - 1 == k){
                    return 0;
                }
                last = (last - 1) / 5;
                k %= last;
            }
            return 5;
        }
    }
}